﻿//----------------------------------------------------
//    版权：
//    作者：
//建立时间：2012-09-11 00:00:33
//    描述：
//----------------------------------------------------
using System;
using System.Data;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Data.Entity;

using WinnerCMS.Common;
using WinnerCMS.Model;
namespace WinnerCMS.Data
{
    /// <summary>
    /// 数据访问层CMS_DiggDiary。
    /// </summary>
    public class DiggDiaryDal
    {
        /// <summary>
        /// 绑定数据
        /// </summary>
        /// <param name="modelId"></param>
        /// <param name="pp"></param>
        /// <returns></returns>
        public IList<DiggDiary> BindList(byte modelId, PagingParam pp)
        {
            using (Entities db = new Entities())
            {
                var query = db.DiggDiares.Include(x => x.Digg.Core);

                pp.RecordCount = query.Count();

                return query.OrderByDescending(x => x.Id).Skip(pp.Skip).Take(pp.PageSize).ToArray();
            }
        }
    }
}